Coverage Report

Created: 2021-08-28 18:14

D:\git\skunkworks\herald-for-cpp\herald-tests\sample-tests.cpp
Line
Count
Source
1
//  Copyright 2021 Herald Project Contributors
2
//  SPDX-License-Identifier: Apache-2.0
3
//
4
5
#include "catch.hpp"
6
7
#include <iterator>
8
9
#include "herald/herald.h"
10
11
1
TEST_CASE("sample-basic", "[sample][basic]") {
12
1
  SECTION("sample-basic") {
13
1
    herald::analysis::sampling::Sample s(herald::datatype::Date(1234), herald::datatype::RSSI(-55));
14
1
15
1
    REQUIRE(s.taken.secondsSinceUnixEpoch() == 1234);
16
1
    REQUIRE(s.value == -55);
17
1
  }
18
1
}
19
20
1
TEST_CASE("sample-from-parts", "[sample][basic]") {
21
1
  SECTION("sample-from-parts") {
22
1
    herald::analysis::sampling::Sample s(herald::datatype::Date(1234), herald::datatype::RSSI(-55));
23
1
    herald::analysis::sampling::Sample s2(s.taken, s.value);
24
1
25
1
    REQUIRE(s2.taken.secondsSinceUnixEpoch() == 1234);
26
1
    REQUIRE(s2.value == -55);
27
1
  }
28
1
}
29
30
1
TEST_CASE("sample-from-parts-deep", "[sample][basic]") {
31
1
  SECTION("sample-from-parts-deep") {
32
1
    herald::analysis::sampling::Sample s(herald::datatype::Date(1234), herald::datatype::RSSI(-55));
33
1
    herald::analysis::sampling::Sample s2(herald::datatype::Date{s.taken.secondsSinceUnixEpoch()}, s.value);
34
1
35
1
    REQUIRE(s2.taken.secondsSinceUnixEpoch() == 1234);
36
1
    REQUIRE(s2.value == -55);
37
1
  }
38
1
}
39
40
1
TEST_CASE("sample-copy-ctor", "[sample][copy][ctor]") {
41
1
  SECTION("sample-copy-ctor") {
42
1
    const herald::analysis::sampling::Sample s(herald::datatype::Date(1234), herald::datatype::RSSI(-55));
43
1
    herald::analysis::sampling::Sample s2(s); // copy ctor
44
1
45
1
    REQUIRE(s2.taken.secondsSinceUnixEpoch() == 1234);
46
1
    REQUIRE(s2.value == -55);
47
1
  }
48
1
}
49
50
1
TEST_CASE("sample-copy-assign", "[sample][copy][assign]") {
51
1
  SECTION("sample-copy-assign") {
52
1
    const herald::analysis::sampling::Sample s(herald::datatype::Date(1234), herald::datatype::RSSI(-55));
53
1
    herald::analysis::sampling::Sample s2 = s; // copy assign
54
1
55
1
    REQUIRE(s2.taken.secondsSinceUnixEpoch() == 1234);
56
1
    REQUIRE(s2.value == -55);
57
1
  }
58
1
}
59
60
1
TEST_CASE("sample-move-ctor", "[sample][move][ctor]") {
61
1
  SECTION("sample-move-ctor") {
62
1
    herald::analysis::sampling::Sample s(herald::datatype::Date(1234), herald::datatype::RSSI(-55));
63
1
    herald::analysis::sampling::Sample s2(std::move(s)); // move ctor
64
1
65
1
    REQUIRE(s2.taken.secondsSinceUnixEpoch() == 1234);
66
1
    REQUIRE(s2.value == -55);
67
1
  }
68
1
}
69
70
1
TEST_CASE("sample-move-assign", "[sample][move][assign]") {
71
1
  SECTION("sample-move-assign") {
72
1
    herald::analysis::sampling::Sample s(herald::datatype::Date(1234), herald::datatype::RSSI(-55));
73
1
    herald::analysis::sampling::Sample s2 = std::move(s); // move assign
74
1
75
1
    REQUIRE(s2.taken.secondsSinceUnixEpoch() == 1234);
76
1
    REQUIRE(s2.value == -55);
77
1
  }
78
1
}
79
80
1
TEST_CASE("samplelist-empty", "[samplelist][empty]") {
81
1
  SECTION("samplelist-empty") {
82
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
83
1
84
1
    REQUIRE(sl.size() == 0);
85
1
    REQUIRE(std::begin(sl) == std::end(sl));
86
1
  }
87
1
}
88
89
1
TEST_CASE("samplelist-singleitem", "[samplelist][singleitem]") {
90
1
  SECTION("samplelist-singleitem") {
91
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
92
1
    sl.push(1234,-55);
93
1
94
1
    REQUIRE(sl.size() == 1);
95
1
    REQUIRE(std::begin(sl) != std::end(sl));
96
1
    REQUIRE(sl[0].value == -55);
97
1
  }
98
1
}
99
100
1
TEST_CASE("samplelist-notfull", "[samplelist][notfull]") {
101
1
  SECTION("samplelist-notfull") {
102
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
103
1
    sl.push(1234,-55);
104
1
    sl.push(1244,-60);
105
1
    sl.push(1265,-58);
106
1
107
1
    REQUIRE(sl.size() == 3);
108
1
    REQUIRE(sl[0].value == -55);
109
1
    REQUIRE(sl[1].value == -60);
110
1
    REQUIRE(sl[2].value == -58);
111
1
  }
112
1
}
113
114
1
TEST_CASE("samplelist-exactlyfull", "[samplelist][exactlyfull]") {
115
1
  SECTION("samplelist-exactlyfull") {
116
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
117
1
    sl.push(1234,-55);
118
1
    sl.push(1244,-60);
119
1
    sl.push(1265,-58);
120
1
    sl.push(1282,-61);
121
1
    sl.push(1294,-54);
122
1
123
1
    REQUIRE(sl.size() == 5);
124
1
    REQUIRE(sl[0].value == -55);
125
1
    REQUIRE(sl[1].value == -60);
126
1
    REQUIRE(sl[2].value == -58);
127
1
    REQUIRE(sl[3].value == -61);
128
1
    REQUIRE(sl[4].value == -54);
129
1
  }
130
1
}
131
132
1
TEST_CASE("samplelist-oneover", "[samplelist][oneover]") {
133
1
  SECTION("samplelist-oneover") {
134
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
135
1
    sl.push(1234,-55);
136
1
    sl.push(1244,-60);
137
1
    sl.push(1265,-58);
138
1
    sl.push(1282,-61);
139
1
    sl.push(1294,-54);
140
1
    sl.push(1302,-47);
141
1
142
1
    REQUIRE(sl.size() == 5);
143
1
    REQUIRE(sl[0].value == -60);
144
1
    REQUIRE(sl[1].value == -58);
145
1
    REQUIRE(sl[2].value == -61);
146
1
    REQUIRE(sl[3].value == -54);
147
1
    REQUIRE(sl[4].value == -47);
148
1
  }
149
1
}
150
151
1
TEST_CASE("samplelist-threeover", "[samplelist][threeover]") {
152
1
  SECTION("samplelist-threeover") {
153
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
154
1
    sl.push(1234,-55);
155
1
    sl.push(1244,-60);
156
1
    sl.push(1265,-58);
157
1
    sl.push(1282,-61);
158
1
    sl.push(1294,-54);
159
1
    sl.push(1302,-47);
160
1
    sl.push(1304,-48);
161
1
    sl.push(1305,-49);
162
1
163
1
    REQUIRE(sl.size() == 5);
164
1
    REQUIRE(sl[0].value == -61);
165
1
    REQUIRE(sl[1].value == -54);
166
1
    REQUIRE(sl[2].value == -47);
167
1
    REQUIRE(sl[3].value == -48);
168
1
    REQUIRE(sl[4].value == -49);
169
1
  }
170
1
}
171
172
1
TEST_CASE("samplelist-justunderfullagain", "[samplelist][justunderfullagain]") {
173
1
  SECTION("samplelist-justunderfullagain") {
174
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
175
1
    sl.push(1234,-55);
176
1
    sl.push(1244,-60);
177
1
    sl.push(1265,-58);
178
1
    sl.push(1282,-61);
179
1
    sl.push(1294,-54);
180
1
    sl.push(1302,-47);
181
1
    sl.push(1304,-48);
182
1
    sl.push(1305,-49);
183
1
    sl.push(1306,-45);
184
1
185
1
    REQUIRE(sl.size() == 5);
186
1
    REQUIRE(sl[0].value == -54);
187
1
    REQUIRE(sl[1].value == -47);
188
1
    REQUIRE(sl[2].value == -48);
189
1
    REQUIRE(sl[3].value == -49);
190
1
    REQUIRE(sl[4].value == -45);
191
1
  }
192
1
}
193
194
1
TEST_CASE("samplelist-fullagain", "[samplelist][fullagain]") {
195
1
  SECTION("samplelist-fullagain") {
196
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
197
1
    sl.push(1234,-55);
198
1
    sl.push(1244,-60);
199
1
    sl.push(1265,-58);
200
1
    sl.push(1282,-61);
201
1
    sl.push(1294,-54);
202
1
    sl.push(1302,-47);
203
1
    sl.push(1304,-48);
204
1
    sl.push(1305,-49);
205
1
    sl.push(1306,-45);
206
1
    sl.push(1307,-44);
207
1
208
1
    REQUIRE(sl.size() == 5);
209
1
    REQUIRE(sl[0].value == -47);
210
1
    REQUIRE(sl[1].value == -48);
211
1
    REQUIRE(sl[2].value == -49);
212
1
    REQUIRE(sl[3].value == -45);
213
1
    REQUIRE(sl[4].value == -44);
214
1
  }
215
1
}
216
217
// Now handle deletion by time
218
219
1
TEST_CASE("samplelist-clearoneold", "[samplelist][clearoneold]") {
220
1
  SECTION("samplelist-clearoneold") {
221
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
222
1
    sl.push(1234,-55);
223
1
    sl.push(1244,-60);
224
1
    sl.push(1265,-58);
225
1
    sl.push(1282,-61);
226
1
    sl.push(1294,-54);
227
1
    sl.push(1302,-47);
228
1
    sl.push(1304,-48);
229
1
    sl.push(1305,-49);
230
1
    sl.push(1306,-45);
231
1
    sl.push(1307,-44);
232
1
233
1
    sl.clearBeforeDate(1304);
234
1
235
1
    REQUIRE(sl.size() == 4);
236
1
    REQUIRE(sl[0].value == -48);
237
1
    REQUIRE(sl[1].value == -49);
238
1
    REQUIRE(sl[2].value == -45);
239
1
    REQUIRE(sl[3].value == -44);
240
1
  }
241
1
}
242
243
1
TEST_CASE("samplelist-clearfourold", "[samplelist][clearfourold]") {
244
1
  SECTION("samplelist-clearfourold") {
245
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
246
1
    sl.push(1234,-55);
247
1
    sl.push(1244,-60);
248
1
    sl.push(1265,-58);
249
1
    sl.push(1282,-61);
250
1
    sl.push(1294,-54);
251
1
    sl.push(1302,-47);
252
1
    sl.push(1304,-48);
253
1
    sl.push(1305,-49);
254
1
    sl.push(1306,-45);
255
1
    sl.push(1307,-44);
256
1
257
1
    sl.clearBeforeDate(1307);
258
1
259
1
    REQUIRE(sl.size() == 1);
260
1
    REQUIRE(sl[0].value == -44);
261
1
  }
262
1
}
263
264
1
TEST_CASE("samplelist-clearallold", "[samplelist][clearallold]") {
265
1
  SECTION("samplelist-clearallold") {
266
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
267
1
    sl.push(1234,-55);
268
1
    sl.push(1244,-60);
269
1
    sl.push(1265,-58);
270
1
    sl.push(1282,-61);
271
1
    sl.push(1294,-54);
272
1
    sl.push(1302,-47);
273
1
    sl.push(1304,-48);
274
1
    sl.push(1305,-49);
275
1
    sl.push(1306,-45);
276
1
    sl.push(1307,-44);
277
1
278
1
    sl.clearBeforeDate(1308);
279
1
280
1
    REQUIRE(sl.size() == 0);
281
1
  }
282
1
}
283
284
// Now handle clear()
285
1
TEST_CASE("samplelist-clear", "[samplelist][clear]") {
286
1
  SECTION("samplelist-clear") {
287
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
288
1
    sl.push(1234,-55);
289
1
    sl.push(1244,-60);
290
1
    sl.push(1265,-58);
291
1
    sl.push(1282,-61);
292
1
    sl.push(1294,-54);
293
1
    sl.push(1302,-47);
294
1
    sl.push(1304,-48);
295
1
    sl.push(1305,-49);
296
1
    sl.push(1306,-45);
297
1
    sl.push(1307,-44);
298
1
299
1
    sl.clear();
300
1
301
1
    REQUIRE(sl.size() == 0);
302
1
  }
303
1
}
304
305
// Now handle iterators
306
1
TEST_CASE("samplelist-iterator-empty", "[samplelist][iterator][empty]") {
307
1
  SECTION("samplelist-iterator-empty") {
308
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
309
1
    
310
1
    auto iter = std::begin(sl);
311
1
    auto endIter = std::end(sl);
312
1
    REQUIRE(iter == endIter);
313
1
    REQUIRE(iter == sl.end());
314
1
    REQUIRE(endIter == sl.begin());
315
1
    REQUIRE(endIter == sl.end());
316
1
  }
317
1
}
318
1
TEST_CASE("samplelist-iterator-single", "[samplelist][iterator][single]") {
319
1
  SECTION("samplelist-iterator-single") {
320
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
321
1
    sl.push(1234,-55);
322
1
    
323
1
    auto iter = std::begin(sl);
324
1
    auto endIter = std::end(sl);
325
1
    REQUIRE(iter != endIter);
326
1
    REQUIRE(iter != sl.end());
327
1
    REQUIRE(endIter != sl.begin());
328
1
    REQUIRE(endIter == sl.end());
329
1
    REQUIRE((*iter).value == -55);
330
1
    ++iter;
331
1
    REQUIRE(iter == endIter);
332
1
  }
333
1
}
334
335
1
TEST_CASE("samplelist-iterator-three", "[samplelist][iterator][three]") {
336
1
  SECTION("samplelist-iterator-three") {
337
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
338
1
    sl.push(1234,-55);
339
1
    sl.push(1244,-60);
340
1
    sl.push(1265,-58);
341
1
    
342
1
    auto iter = std::begin(sl);
343
1
    auto endIter = std::end(sl);
344
1
    REQUIRE(iter != endIter);
345
1
    REQUIRE(iter != sl.end());
346
1
    REQUIRE(endIter != sl.begin());
347
1
    REQUIRE(endIter == sl.end());
348
1
    REQUIRE((*iter).value == -55);
349
1
    ++iter;
350
1
    REQUIRE((*iter).value == -60);
351
1
    ++iter;
352
1
    REQUIRE((*iter).value == -58);
353
1
    ++iter;
354
1
    REQUIRE(iter == endIter);
355
1
  }
356
1
}
357
358
1
TEST_CASE("samplelist-iterator-exactlyfull", "[samplelist][iterator][exactlyfull]") {
359
1
  SECTION("samplelist-iterator-exactlyfull") {
360
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
361
1
    sl.push(1234,-55);
362
1
    sl.push(1244,-60);
363
1
    sl.push(1265,-58);
364
1
    sl.push(1282,-61);
365
1
    sl.push(1294,-54);
366
1
    
367
1
    auto iter = std::begin(sl);
368
1
    auto endIter = std::end(sl);
369
1
    REQUIRE(iter != endIter);
370
1
    REQUIRE(iter != sl.end());
371
1
    REQUIRE(endIter != sl.begin());
372
1
    REQUIRE(endIter == sl.end());
373
1
    REQUIRE((*iter).value == -55);
374
1
    ++iter;
375
1
    REQUIRE((*iter).value == -60);
376
1
    ++iter;
377
1
    REQUIRE((*iter).value == -58);
378
1
    ++iter;
379
1
    REQUIRE((*iter).value == -61);
380
1
    ++iter;
381
1
    REQUIRE((*iter).value == -54);
382
1
    ++iter;
383
1
    REQUIRE(iter == endIter);
384
1
  }
385
1
}
386
387
1
TEST_CASE("samplelist-iterator-oneover", "[samplelist][iterator][oneover]") {
388
1
  SECTION("samplelist-iterator-oneover") {
389
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
390
1
    sl.push(1234,-55);
391
1
    sl.push(1244,-60);
392
1
    sl.push(1265,-58);
393
1
    sl.push(1282,-61);
394
1
    sl.push(1294,-54);
395
1
    sl.push(1302,-47);
396
1
    
397
1
    auto iter = std::begin(sl);
398
1
    auto endIter = std::end(sl);
399
1
    REQUIRE(iter != endIter);
400
1
    REQUIRE(iter != sl.end());
401
1
    REQUIRE(endIter != sl.begin());
402
1
    REQUIRE(endIter == sl.end());
403
1
    REQUIRE((*iter).value == -60);
404
1
    ++iter;
405
1
    REQUIRE((*iter).value == -58);
406
1
    ++iter;
407
1
    REQUIRE((*iter).value == -61);
408
1
    ++iter;
409
1
    REQUIRE((*iter).value == -54);
410
1
    ++iter;
411
1
    REQUIRE((*iter).value == -47);
412
1
    ++iter;
413
1
    REQUIRE(iter == endIter);
414
1
  }
415
1
}
416
417
1
TEST_CASE("samplelist-iterator-twoover", "[samplelist][iterator][twoover]") {
418
1
  SECTION("samplelist-iterator-twoover") {
419
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
420
1
    sl.push(1234,-55);
421
1
    sl.push(1244,-60);
422
1
    sl.push(1265,-58);
423
1
    sl.push(1282,-61);
424
1
    sl.push(1294,-54);
425
1
    sl.push(1302,-47);
426
1
    sl.push(1304,-48);
427
1
    
428
1
    auto iter = std::begin(sl);
429
1
    auto endIter = std::end(sl);
430
1
    REQUIRE(iter != endIter);
431
1
    REQUIRE(iter != sl.end());
432
1
    REQUIRE(endIter != sl.begin());
433
1
    REQUIRE(endIter == sl.end());
434
1
    REQUIRE((*iter).value == -58);
435
1
    ++iter;
436
1
    REQUIRE((*iter).value == -61);
437
1
    ++iter;
438
1
    REQUIRE((*iter).value == -54);
439
1
    ++iter;
440
1
    REQUIRE((*iter).value == -47);
441
1
    ++iter;
442
1
    REQUIRE((*iter).value == -48);
443
1
    ++iter;
444
1
    REQUIRE(iter == endIter);
445
1
  }
446
1
}
447
448
1
TEST_CASE("samplelist-iterator-fullagain", "[samplelist][iterator][fullagain]") {
449
1
  SECTION("samplelist-iterator-fullagain") {
450
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
451
1
    sl.push(1234,-55);
452
1
    sl.push(1244,-60);
453
1
    sl.push(1265,-58);
454
1
    sl.push(1282,-61);
455
1
    sl.push(1294,-54);
456
1
    sl.push(1302,-47);
457
1
    sl.push(1304,-48);
458
1
    sl.push(1305,-49);
459
1
    sl.push(1306,-45);
460
1
    sl.push(1307,-44);
461
1
    
462
1
    auto iter = std::begin(sl);
463
1
    auto endIter = std::end(sl);
464
1
    REQUIRE(iter != endIter);
465
1
    REQUIRE(iter != sl.end());
466
1
    REQUIRE(endIter != sl.begin());
467
1
    REQUIRE(endIter == sl.end());
468
1
    REQUIRE((*iter).value == -47);
469
1
    ++iter;
470
1
    REQUIRE((*iter).value == -48);
471
1
    ++iter;
472
1
    REQUIRE((*iter).value == -49);
473
1
    ++iter;
474
1
    REQUIRE((*iter).value == -45);
475
1
    ++iter;
476
1
    REQUIRE((*iter).value == -44);
477
1
    ++iter;
478
1
    REQUIRE(iter == endIter);
479
1
  }
480
1
}
481
482
1
TEST_CASE("samplelist-iterator-cleared", "[samplelist][iterator][cleared]") {
483
1
  SECTION("samplelist-iterator-cleared") {
484
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,5> sl;
485
1
    sl.push(1234,-55);
486
1
    sl.push(1244,-60);
487
1
    sl.push(1265,-58);
488
1
    sl.push(1282,-61);
489
1
    sl.push(1294,-54);
490
1
    sl.push(1302,-47);
491
1
    sl.push(1304,-48);
492
1
    sl.push(1305,-49);
493
1
    sl.push(1306,-45);
494
1
    sl.push(1307,-44);
495
1
496
1
    sl.clear();
497
1
    
498
1
    auto iter = std::begin(sl);
499
1
    auto endIter = std::end(sl);
500
1
    REQUIRE(iter == endIter);
501
1
    REQUIRE(iter == sl.end());
502
1
    REQUIRE(endIter == sl.begin());
503
1
    REQUIRE(endIter == sl.end());
504
1
  }
505
1
}
506
507
// Now handle other container functionality required
508
509
1
TEST_CASE("sample-init-list", "[sample][initialiser][list]") {
510
1
  SECTION("sample-init-list") {
511
1
    herald::analysis::sampling::Sample<herald::datatype::RSSI> sample{10,-55};
512
1
    REQUIRE(sample.taken.secondsSinceUnixEpoch() == 10);
513
1
    REQUIRE(sample.value == -55);
514
1
  }
515
1
}
516
517
1
TEST_CASE("samplelist-init-list", "[samplelist][initialiser][list]") {
518
1
  SECTION("samplelist-init-list") {
519
1
    herald::analysis::sampling::Sample<herald::datatype::RSSI> sample1{10,-55};
520
1
    herald::analysis::sampling::Sample<herald::datatype::RSSI> sample2{20,-65};
521
1
    herald::analysis::sampling::Sample<herald::datatype::RSSI> sample3{30,-75};
522
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,3> sl{sample1,sample2,sample3};
523
1
    REQUIRE(sl[0].taken.secondsSinceUnixEpoch() == 10);
524
1
    REQUIRE(sl[0].value == -55);
525
1
    REQUIRE(sl[1].taken.secondsSinceUnixEpoch() == 20);
526
1
    REQUIRE(sl[1].value == -65);
527
1
    REQUIRE(sl[2].taken.secondsSinceUnixEpoch() == 30);
528
1
    REQUIRE(sl[2].value == -75);
529
1
  }
530
1
}
531
532
1
TEST_CASE("samplelist-init-list-deduced", "[samplelist][initialiser][list][deduced]") {
533
1
  SECTION("samplelist-init-list-deduced") {
534
1
    herald::analysis::sampling::Sample<herald::datatype::RSSI> sample1{10,-55};
535
1
    herald::analysis::sampling::Sample<herald::datatype::RSSI> sample2{20,-65};
536
1
    herald::analysis::sampling::Sample<herald::datatype::RSSI> sample3{30,-75};
537
1
    herald::analysis::sampling::SampleList sl{sample1,sample2,sample3}; // full type is deduced
538
1
    REQUIRE(sl[0].taken.secondsSinceUnixEpoch() == 10);
539
1
    REQUIRE(sl[0].value == -55);
540
1
    REQUIRE(sl[1].taken.secondsSinceUnixEpoch() == 20);
541
1
    REQUIRE(sl[1].value == -65);
542
1
    REQUIRE(sl[2].taken.secondsSinceUnixEpoch() == 30);
543
1
    REQUIRE(sl[2].value == -75);
544
1
  }
545
1
}
546
547
1
TEST_CASE("samplelist-init-list-alldeduced", "[samplelist][initialiser][list][alldeduced]") {
548
1
  SECTION("samplelist-init-list-alldeduced") {
549
1
    herald::analysis::sampling::SampleList<herald::analysis::sampling::Sample<herald::datatype::RSSI>,3> sl{
550
1
      herald::analysis::sampling::Sample<herald::datatype::RSSI>{10,-55},
551
1
      herald::analysis::sampling::Sample<herald::datatype::RSSI>{20,-65},
552
1
      herald::analysis::sampling::Sample<herald::datatype::RSSI>{30,-75}
553
1
    };
554
1
    REQUIRE(sl[0].taken.secondsSinceUnixEpoch() == 10);
555
1
    REQUIRE(sl[0].value == -55);
556
1
    REQUIRE(sl[1].taken.secondsSinceUnixEpoch() == 20);
557
1
    REQUIRE(sl[1].value == -65);
558
1
    REQUIRE(sl[2].taken.secondsSinceUnixEpoch() == 30);
559
1
    REQUIRE(sl[2].value == -75);
560
1
  }
561
1
}